package com.kd.service.admin.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kd.bean.admin.Admin_msg;
import com.kd.dao.admin.IAdmin_msgDao;
import com.kd.service.admin.IAdmin_msgService;

@Service
@Transactional
public class Admin_msgServiceImpl implements IAdmin_msgService{

	@Autowired
	private IAdmin_msgDao admin_msgDao;
	
	@PostConstruct
	public void createAdmin() {
		//自定义初始方法
		try {
			List<Admin_msg> list = admin_msgDao.queryAllAdmin();
			if(list==null || list.size()<=0) {
				Admin_msg admin = new Admin_msg();
				admin.setAdmin_account("admin");
				admin.setAdmin_password("jobAdmin9527");
				admin.setCreate_time(new Date());
				admin_msgDao.insertAdminMsg(admin);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	@Override
	public Admin_msg adminLogin(Admin_msg admin) throws Exception {
		
		return admin_msgDao.adminLogin(admin);
	}

}
